public class PreorderTree extends SortedTree{

	public PreorderTree(String node) {
		super(node);
	}

	@Override
	public String traverse(){
	
		// when we are in the ghost-root, we just call traverse of the actual root
		if(getParentNode() == null){
			return ((PreorderTree)getLeft()).traverse();
		}
	
		String trav = getLabel();
		
		if(super.getLeft() != null)
			trav+=((SortedTree)super.getLeft()).traverse();
			
		if(super.getRight() != null)
			trav+=((SortedTree)super.getRight()).traverse();
		
		return trav;
	}

	@Override
	protected SortedTree getChildElement(String node) {
		PreorderTree elem = new PreorderTree(null);
		elem.setLabel(node);
		return elem;
	}
}